export class CD extends plugin {

  constructor() {
    super({
      name: '刷新CD',
      dsc: '刷新抽卡、面板、扫码登录cd！',
      event: 'message',
      priority: 100,
      rule: [
        {
          reg: '^#?(刷新|清除|clean-)(CD|cd)\s*([1-9][0-9]{8})?$',
          fnc: 'cleanCD',
          // permission: 'master',  // 可自行修改，取消注释为主人可用
        },
      ],
    })
  }

  async cleanCD(e) {
    const uidList = []
    const user_id = e.at ? e.at : e.user_id
    uidList.push(...e.user.getUidList("gs"))
    uidList.push(...e.user.getUidList("sr"))

    try {
      redis.del(`xiaoyao:gclog:${user_id}`)
      redis.del(`xiaoyao:GetQrCode:${user_id}`)
    } catch (error) { }

    if (uidList && uidList.length > 1) {
      for (const i of uidList) {
        try {
          redis.del(`miao:profile-cd:${i.uid}`)
        } catch (error) { }
      }
    }

    if (user_id === e.user_id) {
    return await e.reply(`已刷新\n更新抽卡记录、扫码绑定CD！`, true)
    }
  }

}
